<?php
   
class API_Utils extends API_Class {
    protected static $loc = NULL;
    
    public function getLocalised($p){
        if(self::$loc == NULL)
            self::$loc = self::loadJson('localise');
        return self::$loc[$p];
    }
    
    public function getLocMonth($time, $pad = ''){
        $mons = self::getLocalised('months'.$pad);
        $m = (int)($time<=12 ? $time : date("m", $time));
        return $mons[$m];
    }
    
    public function loadJson($file){
        $tf = join('', file(DATA_PATH.$file.'.json'));
        return Zend_Json::decode($tf);
    }
    
    public function ansi_to_utf($obj){
        if(is_array($obj)){
            foreach($obj as &$val)
                $val = self::ansi_to_utf($val);
        } elseif(is_string($obj)) {
            $obj = iconv("CP1251", "UTF-8", $obj);
        }
        return $obj;                
    }
    
}